package com.ojoin.ojoin.eb_spider.service;

import java.io.IOException;
import java.util.List;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.springframework.stereotype.Service;

@Service
public interface WebDriverService{

	final String CSS = "css";
	final String ID = "id";
	final String xpath = "xpath";
	final String className = "className";
	final String tagName = "tagName";

	public WebDriver getDriver();

	public WebElement findElement(String pathType, String path);


	public WebElement findElement(WebElement element, String pathType,
			String path);

	public void initWebDriver(String downloadFilepath) throws Exception;

	public void initRemoteWebDriver(String downloadFilepath) throws Exception;

	public void initRemoteWebDriver() throws Exception;

	public void initWebDriver() throws Exception;
	
	public boolean initCookies(String uid, String platformName) throws IOException, Exception;
	 
	public void get(String url);

	public String getText(WebElement element, String pathType, String path);

	public String getText(String pathType, String path);
	
	public String getTextHasException(WebElement element, String pathType, String path);

	public String getTextHasException(String pathType, String path);
	

	public <T> T execJavaScript(String paramString);

	public void sendKeys(String pathType, String path, String value);

	public void sendKeys(WebElement element, String value);

	public void click(String pathType, String path);
	
	public void click(String pathType, String path,int senconds);

	
	public void click(WebElement element,String pathType, String path);

	public boolean isLogin(final String url);

	/**
	 * 等待元素加载完成
	 * 
	 * @param pathType
	 * @param path
	 * @return
	 */
	public WebElement waitVisibilityOfElementLocated(String pathType,
			String path);

	public void selectByValue(String pathType, String path, String value);

	public void selectByValue(WebElement element, String value);

	public WebDriverWait getWebDriverWait(int times);

	public List<WebElement> findElements(WebElement element, String pathType,
			String path);

	public List<WebElement> findElements(String pathType, String path);

	public void clickByJS(String pathType, String path);
	
	public void clickdblByJS(String pathType, String path);

	public String clickByJS(WebElement store_date);

	public String getTextByJS(WebElement element, String pathType, String path);

	public String getTextByJS(String pathType, String path);

	public String getTextByJS(WebElement store_date);

	public boolean IsDisplayed(String pathType, String path);

	public void checkAlert();

	public String  getAlertText() ;
	
	public void close();

	// 获取图片字节流
	public byte[] getIMGByte(Object o);

	// 获取验证码
	public String getVerifyCode(Object o) throws Exception;

	public String clearByJS(WebElement store_date);

	public void switchToframe(String name);

	public void switchToDefaultContent();

	public void switchToframe(WebElement frame);

	public void waitForPageLoad();

	public boolean createByCookie(String uid, String platformName)
			throws Exception;
	
	public void clickWaitForPage(String pathType, String path);

	public void getAndPageLoad(String url);

	public void waitForAjaxOver();

	public boolean IsExist(WebElement element,String pathType, String path);

	public boolean IsExist(String pathType, String path);
	/**
	 * 等待元素加载完成
	 * 
	 * @param pathType
	 * @param path
	 * @param millisecond
	 * @return
	 */
	public WebElement waitVisibilityOfElementLocated(String pathType,
			String path, int millisecond);

	/**
	 * 保存cookie
	 * 
	 * @param uid
	 * @throws IOException
	 */
	public void saveCookies(String uid) throws IOException;
	
	/**
	 * 获取 Node IP 
	 * @param sessionId
	 * @return
	 */
	String getproxyId(String sessionId) ;
	
	String getVerifyCodeByDMV3(Object o) throws Exception;

}
